home *** CD-ROM | disk | FTP | other *** search
/ Champak 29 / Volume 29 - JOGO DISK .iso / Games / jungle_adventure.swf / scripts / __Packages / Explosive.as < prev    next >
Text File  |  2006-11-29  |  2KB  |  72 lines

  1. class Explosive extends SSObject
  2. {
  3.    var classID = SSGlobal.CLSID_OBJECT;
  4.    var collisionMask = SSGlobal.CLSID_SHAPE;
  5.    var camStallTime = 0.5;
  6.    var value = -0.5;
  7.    var strength = 1500;
  8.    var reappear = false;
  9.    var particle = "Smoke";
  10.    var assetID = "Explosive";
  11.    var soundID = "Bomb";
  12.    var editor_isItem = true;
  13.    var editor_name = "Explosive";
  14.    var editor_args_names = ["damage","strength","reappear","camDelay","particle"];
  15.    var editor_args_values = [Explosive.prototype.value,Explosive.prototype.strength,Explosive.prototype.reappear,Explosive.prototype.camStallTime,Explosive.prototype.particle];
  16.    var editor_args_types = ["number","number","boolean","number","string"];
  17.    var editor_args_options = [[-1,1,0.01],[20,10000,20],null,[0,1,0.01],"A-Za-z0-9"];
  18.    var editor_args_descriptions = ["","","","",""];
  19.    var editor_args_mode = [0,0,0,0,0];
  20.    var editor_args_component = ["NumericStepper","NumericStepper","CheckBox","NumericStepper","TextInput"];
  21.    function Explosive(damage, strength, regenerate, camDelay, particle)
  22.    {
  23.       super();
  24.       if(damage)
  25.       {
  26.          this.value = damage;
  27.       }
  28.       if(strength)
  29.       {
  30.          this.strength = strength;
  31.       }
  32.       if(regenerate)
  33.       {
  34.          this.reappear = regenerate;
  35.       }
  36.       if(camDelay)
  37.       {
  38.          this.camStallTime = camDelay;
  39.       }
  40.       if(particle.length)
  41.       {
  42.          this.particle = particle;
  43.       }
  44.    }
  45.    function onCollision(obj)
  46.    {
  47.       if(!this.inScene)
  48.       {
  49.          return undefined;
  50.       }
  51.       var _loc3_ = undefined;
  52.       (_loc3_ = new Vector(obj.x - this.x,obj.y - this.y,0)).normalize();
  53.       obj.shiftHealth(this.value,this);
  54.       GameSound.playSound(this.soundID);
  55.       obj.velocity.x = _loc3_.x * this.strength;
  56.       obj.velocity.y = _loc3_.y * this.strength + 100;
  57.       obj.motionTime = 0.0001;
  58.       obj.emitParticle(this.particle,4);
  59.       this.world.viewport.stall(this.camStallTime);
  60.       this.world.viewport.shakeCamera(0.1,8);
  61.       if(this.reappear)
  62.       {
  63.          this.removeFromScene();
  64.       }
  65.       else
  66.       {
  67.          this.world.removeObject(this);
  68.       }
  69.       return GDK.Node.COLLISION_CANCEL;
  70.    }
  71. }
  72.